home *** CD-ROM | disk | FTP | other *** search
- Path: news.ov.com!news
- From: glenn@ov.com (Fletcher.Glenn@ov.com)
- Newsgroups: comp.lang.c
- Subject: Re: Help
- Date: 11 Apr 1996 16:14:29 GMT
- Organization: OpenVision
- Message-ID: <4kjb55$7fm@spanky.pls.ov.com>
- References: <316C3043.A5D@hlp.com>
- Reply-To: glenn@ov.com
- NNTP-Posting-Host: foghorn.pls.ov.com
-
- In article A5D@hlp.com, andrew kennedy <"andrew kennedy"@hlp.com> writes:
- >This is a multi-part message in MIME format.
- >
- >--------------66794A10240E
- >Content-Type: text/plain; charset=us-ascii
- >Content-Transfer-Encoding: 7bit
- >
- >I wrote this code early in my C career, but there should be a better to
- >do this. Can someone help.
- >
- >--------------66794A10240E
- >Content-Type: text/plain; charset=us-ascii
- >Content-Transfer-Encoding: 7bit
- >Content-Disposition: inline; filename="PROB"
- >
- >
- > if( !strchr(file_name, '.')) /*if file has no extension, take on .enc*/
- > {
- > strcpy(name1,file_name);
- > strcpy(name2,file_name);
- > strcat(name2, ".enc");
- > }
- > else
- > {
- > strcpy(name1, file_name);
- > strcpy(name2, file_name);
- > strrev(name2); /* reverse string i.e. hello = olleh */
- > rev_string = strpbrk(name2,".");
- > /* make rev_string contain only those */
- > /* characters on right side of period */
- > /* and then take off the period */
- >
- > /* works ONLY with file names with */
- > /* the underscore, alphabetic and */
- > /* numeric characters */
- >
- > rev_string = strpbrk(rev_string,"abcdefghijklmnopqrstuvwxyz_0123456789");
- > strrev(rev_string); /* reverse string again to get only */
- > strcpy(name2,rev_string);/* filename without it's extension */
- > strcat(name2, ".enc"); /* copy .enc extension onto name2 */
- > }
- >
- >--------------66794A10240E--
- >
-
-
- The untested code below will replace the extension with .enc.
-
- strcpy(name1, file_name); /* we need this copy in either case */
-
- if (strchr(name1, '.'))
- {
- *strchr(name1, '.') = '\0'; /* the if test above insures valid address */
- }
- sprintf(name2, "%s.enc", name1);
-
- Fletcher.Glenn@ov.com
-
-